<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 函数冒泡排序
        function exchange(number) {
            // 外层趟数
            for (var i = 0; i < number.length - 1; i++) {
                // 内层交换次数
                for (var j = 0; j < number.length - 1 - i; j++) {
                    if (number[j] > number[j + 1]) {
                        var temp = number[j];
                        number[j] = number[j + 1];
                        number[j + 1] = temp;
                    }
                }
            }
            return number;
        }
       var newNumber = exchange([1,3,2,5,4]); 
       alert( newNumber );
       console.log(newNumber);
    </script>
</body>

</html>